package DownloadVideo;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileOutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

/**
 * Created by Administrator on 2016/12/26 0026.
 */
public class DownloadVideo {
    public static void test(String down_url,String filePath)throws Exception{
        DataOutputStream out = null;
        DataInputStream in = null;
        URL url;
        url = new URL(down_url);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        in = new DataInputStream(connection.getInputStream());

        out = new DataOutputStream(new FileOutputStream(filePath));
        byte[] buffer = new byte[4096];
        int count = 0;
        while ((count = in.read(buffer)) > 0)
        {
            out.write(buffer, 0, count);
        }
    }
}
